from comment.utils.Serializers import BasePaginateSerializer

class LetterPaginateSerializer(BasePaginateSerializer):
    """
    继承父类，同时子类需要把消息列表数据，进行序列化
    """
    def get_object(self, obj):
        return {
            'id': obj.id,
            'sendName': obj.sendID,  # 发送者ID
            'detail_id': obj.detail_id,  # 信件详情id
            'title': obj.letter_detail.title,  # 信件标题
            'detail': obj.letter_detail.detail,  # 信件详细内容
            'state': obj.state,                  # 信件已读状态
            'sendTime': obj.letter_detail.pDate.strftime("%Y-%m-%d, %H:%M:%S")  # 发送时间
        }